<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '查看'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="用户类型:">
            <span>{{memberType[dataForm.userType]}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="创建时间:">
            <span>{{dataForm.createTime}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="名称:">
            <span>{{dataForm.partnerName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="联系电话:">
            <span>{{dataForm.partnerIphone}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="联系地址:">
            <span>{{dataForm.partnerAddress}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="合作类型:">
            <span>{{dataForm.cooperateType === 1 ? '商家入驻' : '品牌合作'}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="合作内容:">
            <span>{{dataForm.cooperateContent}}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span> -->
  </el-dialog>
</template>

<script>
  import {typeNameList, typeName} from '@/utils/memberType'
  export default {
    data () {
      return {
        visible: false,
        typeNameList: typeNameList,
        memberType: typeName,
        dataForm: {
          id: 0,
          userId: '',
          userType: '',
          createTime: '',
          partnerName: '',
          partnerIphone: '',
          partnerAddress: '',
          cooperateType: '',
          cooperateContent: '',
          handleState: '',
          handleTime: ''
        },
        dataRule: {}
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/cooperation/getBusinessCooperationInfoId/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.userId = data.data.userId
                this.dataForm.userType = data.data.userType
                this.dataForm.createTime = data.data.createTime
                this.dataForm.partnerName = data.data.partnerName
                this.dataForm.partnerIphone = data.data.partnerIphone
                this.dataForm.partnerAddress = data.data.partnerAddress
                this.dataForm.cooperateType = data.data.cooperateType
                this.dataForm.cooperateContent = data.data.cooperateContent
                // this.dataForm.handleState = data.data.handleState
                // this.dataForm.handleTime = data.data.handleTime
              }
            })
          }
        })
      }
    }
  }
</script>
